<style>
	.menuPermissionNestableListTree .dd-item {cursor:move;}
</style>
<div class="col-lg-12 col-sm-12 col-xs-12">
    <h5 class="row-title" style="width: 100%">
        <div class="row">
        	<div class="col-lg-6 col-sm-6 col-xs-6">
	          	  菜单权限权重调整
	        </div>
	        <div class="col-lg-6 col-sm-6 col-xs-6 text-align-right">
	            <button class="btn btn-success" onclick="setPermissionWeight()"><i class="fa fa-mail-reply"></i>重置</button>
	            <button class="btn btn-danger" id="savePermissionWeightBtn" style="display: none" onclick="savePermissionWeight()"><i class="fa  fa-save"></i>保存</button>
	        </div>
        </div>
    </h5>
    <div class="menuPermissionNestableListTree shadowed">
        <!-- 动态加载 -->
       	加载中……
    </div>
</div>
<script src="assets/js/nestable/jquery.nestable.min.js"></script>
<script type="text/javascript">
    ajaxRequest("permissionSetting/getMenuPermissionsNestable.do", {}, function (result) {
        if (result.resCode == "200") {
            $('.menuPermissionNestableListTree').html(result.data).nestable({
                rootClass: "menuPermissionNestableListTree",
                maxDepth: 50//最高支持50级
            });
            $('.dd-handle a').on('mousedown', function (e) {
                e.stopPropagation();
            });
        } else {
            $('.menuPermissionNestableListTree').html(data.resMsg);
        }
    },
    function (XMLHttpRequest, textStatus, errorThrown) {
        ajaxError(errorThrown);
        $('.menuPermissionNestableListTree').html("加载失败!");
    }, "GET", "JSON");
    $('.menuPermissionNestableListTree').on('change', function() {
       $("#savePermissionWeightBtn").show()
    });
    //保存权重
    function savePermissionWeight() {
        var weightSortJson=$('.menuPermissionNestableListTree').nestable('serialize');
        console.log(weightSortJson);
        ajaxRequest("permissionSetting/savePermissionWeight.do", {weightSortJson:JSON.stringify(weightSortJson)}, function (result) {
            alert(result.resMsg);
        },
        function (XMLHttpRequest, textStatus, errorThrown) {
            ajaxError(errorThrown);
        }, "POST", "JSON");
    }
</script>

